<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
    </head>
    <body>
        
    </body>
</html>
<script>
    var str = "hello, " + "world";
    console.log(str);

    str = 5 + 5;
    console.log(str);

    str = "5" + 5;
    console.log(str);

    
    // 1. 顺序结构
    var a = 5;
    var b = 3;
    var c = a + b;
    console.log(c);

    // 2. 分支结构
    a = 3;
    if (a == 3) {
        console.log("a == 3");
    }

    console.log(a);


    a = 6;
    if (a % 2 == 0) {
        console.log("偶数");
    } else {
        console.log("奇数");
    }


    // 逻辑运算符
    var flag = 5 > 3 && 3 > 8;
    console.log(flag);

    flag = 5 > 3 || 3 > 8;
    console.log(flag);



    // 判断平年闰年
    // 闰年的条件: 能被400整除，或者能被4整除但不能被100整除的年份
    // 400, 2000, 2004, 2100（平年）
    var year = 2000, month = 3, day = 2;
    var isLeapYear = year % 4 == 0 && year % 100 != 0 || year % 400 == 0;
    console.log(isLeapYear);
    // 如果是闰年, 二月份是29天
    var febDay = 28;
    if (isLeapYear) {
        febDay++;
    }

    if (month == 1) {
        console.log("这是一年的第" + day + "天");
    } else if (month == 2) {
        var whichDay = 31 + day;
        console.log("这是一年的第" + whichDay + "天");
    } else if (month == 3) {
        var whichDay = 31 + febDay + day;
        console.log("这是一年的第" + whichDay + "天");
    } else if (month == 4) {
        var whichDay = 31 + febDay + 31 + day;
        console.log("这是一年的第" + whichDay + "天");
    }


    // 3. 循环结构
    // document.write("*");
    // document.write("*");
    // document.write("*");
    // document.write("*");
    // document.write("*");
    // document.write("*");
    // document.write("*");
    // document.write("*");
    // document.write("*");
    // document.write("*");
    // document.write("<br>");
    // document.write("*");
    // document.write("*");
    // document.write("*");
    // document.write("*");
    // document.write("*");
    // document.write("*");
    // document.write("*");
    // document.write("*");
    // document.write("*");
    // document.write("*");
    // document.write("<br>");
    for (var i = 1; i < 10; i += 2) {
        document.write("*");
    }











</script>